package com.yc.sole.common.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author yizuomin
 * @date 2022/11/24 19:19
 **/
@Getter
@AllArgsConstructor
public enum ApprovalState implements IBaseEnum<String> {

    /**
     *
     */
    WAIT("0", "待提交"),
    IN_APPROVAL("1", "进行中"),
    PASS("2", "已通过"),
    REJECT("3", "已驳回"),
    REVOKE("4", "申请人撤回");

    @JsonValue
    private final String value;
    private final String description;

    /**
     * 根据审批状态获取描述
     *
     * @param state
     * @return
     */
    public static String getDescByValue(String state) {
        for (ApprovalState value : ApprovalState.values()) {
            if (value.getValue().equals(state)) {
                return value.getDescription();
            }
        }
        return null;
    }

    /**
     * 根据审批状态获取描述
     *
     * @param approvalState
     * @return
     */
    public static String getDescByValue(ApprovalState approvalState) {
        for (ApprovalState value : ApprovalState.values()) {
            if (value.equals(approvalState)) {
                return value.getDescription();
            }
        }
        return null;
    }
}
